package android.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class ShowLocations extends Activity{

	//kreiranje na konstanti zaradi polesno manipuliranje so podatocite
	private static final int BANK_DIALOG = 5;
	private static final int CHEMIST_DIALOG = 6;
	private static final int SHOP_DIALOG = 7;
	private static final int FUN_DIALOG = 8;
	
	//kreiranje niza od stringovi za prikaz vo dijalog
	CharSequence[] items = {"Show words for this section.", "Show dialogues for this section."};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.locations);
		
	//se zema id-to na kopce za povrzuvanje so nastan
	Button btnBack=(Button)findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new View.OnClickListener() {
		
		public void onClick(View v) {
			//se vrsi isklucuvanje na activity
			finish();	
		}
	});
	
	//se zema id-to na kopce za povrzuvanje so nastan
	Button btnBank=(Button)findViewById(R.id.btnBank);
	btnBank.setOnClickListener(new View.OnClickListener() {
		
		public void onClick(View v) {
				
			showDialog(BANK_DIALOG);
		}
	});
	
	//se zema id-to na kopce za povrzuvanje so nastan
	Button btnChemist=(Button)findViewById(R.id.btnChemist);
	btnChemist.setOnClickListener(new View.OnClickListener() {
		
		public void onClick(View v) {
				
			showDialog(CHEMIST_DIALOG);
		}
	});
	
	//se zema id-to na kopce za povrzuvanje so nastan
	Button btnShop=(Button)findViewById(R.id.btnShop);
	btnShop.setOnClickListener(new View.OnClickListener() {
		
		public void onClick(View v) {

			showDialog(SHOP_DIALOG);
		}
	});
	
	//se zema id-to na kopce za povrzuvanje so nastan
	Button btnFun=(Button)findViewById(R.id.btnFun);
	btnFun.setOnClickListener(new View.OnClickListener() {
		
		public void onClick(View v) {
				
			showDialog(FUN_DIALOG);
		}
	});
	}

	/*
	 * (non-Javadoc)
	 * @see android.app.Activity#onCreateDialog(int)
	 * kreiranje na dijalozi
	 * so pomos na switch se kreiraat poveke dijalozi i vo zavisnost od toa so koe id ke 
	 * se sovpadne pri baranje za startuvanje na dijalog ke se startuva dijalogot cie 
	 * id se sovpaga so baranoto
	 */
	@Override
	protected Dialog onCreateDialog(int id) {
		
		switch(id)
		{
		case BANK_DIALOG:
			return new AlertDialog.Builder(this)
			.setIcon(R.drawable.bank)
			.setTitle("Bank")
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					dialog.cancel();					
				}
			})
			.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					if(items[which].equals("Show words for this section."))
					{
						Intent intent= new Intent(getBaseContext(), android.activity.Bank.class);
						startActivity(intent);
					}
					else
					{
						Intent intentD= new Intent(getBaseContext(), android.activity.BankDialogue.class);
						startActivity(intentD);
					}
				}
			}).create();
			
		case CHEMIST_DIALOG:
			return new AlertDialog.Builder(this)
			.setIcon(R.drawable.chemist)
			.setTitle("Chemist")
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					dialog.cancel();					
				}
			})
			.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					if(items[which].equals("Show words for this section."))
					{
						Intent intent= new Intent(getBaseContext(), android.activity.Chemist.class);
						startActivity(intent);
					}
					else
					{
						Intent intentD= new Intent(getBaseContext(), android.activity.ChemistDialogue.class);
						startActivity(intentD);
					}
				}
			}).create();
			
		case SHOP_DIALOG:
			return new AlertDialog.Builder(this)
			.setIcon(R.drawable.shop)
			.setTitle("Shopping")
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					dialog.cancel();					
				}
			})
			.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					if(items[which].equals("Show words for this section."))
					{
						Intent intent= new Intent(getBaseContext(), android.activity.Shop.class);
						startActivity(intent);
					}
					else
					{
						Intent intentD= new Intent(getBaseContext(), android.activity.ShopDialogue.class);
						startActivity(intentD);
					}
				}
			}).create();
			
		case FUN_DIALOG:
			return new AlertDialog.Builder(this)
			.setIcon(R.drawable.fun)
			.setTitle("Sport & Entertainment")
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					dialog.cancel();					
				}
			})
			.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int which) {
					
					if(items[which].equals("Show words for this section."))
					{
						Intent intent= new Intent(getBaseContext(), android.activity.Fun.class);
						startActivity(intent);
					}
					else
					{
						Intent intentD= new Intent(getBaseContext(), android.activity.FunDialogue.class);
						startActivity(intentD);
					}
				}
			}).create();
		}
		return null;
	}

}
